#include "partner.h"
#include <QHostAddress>
#include <QMouseEvent>
#include <QDebug>

Partner::Partner(QWidget *parent, quint32 p)
    : QLabel{parent}{
    ip = p;
    this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    w = ((QWidget *)this->parent())->size().width();
    this->setPixmap(QPixmap::fromImage(QImage(":/myImage/1.jpg").scaled(w - 10, w - 10)));
    this->setFrameShape(QFrame::Box);

    this->setStyleSheet("border-width: 1px; border-strle: solid; border-color:rgba(0,0,255,0.7)");

    this->setToolTip(QHostAddress(ip).toString());
}

void Partner::mousePressEvent(QMouseEvent *ev)
{
    if(ev->buttons() & Qt::LeftButton)
        emit sendip(ip);
}

void Partner::setpic(QImage img)
{
    this->setPixmap(QPixmap::fromImage(img.scaled(w-10, w-10)));
}
